#include <iostream>
#include <cmath>
using namespace std;
int main()
{
  int w,m,n;
  cin>>w>>m>>n;
  int x1,y1,x2,y2;
  x1=m%w==0?m/w:m/w+1;
  y1=m%w==0?w:m%w;
  if(x1%2==0)y1=w-y1+1;
  x2=n%w==0?n/w:n/w+1;
  y2=n%w==0?w:n%w;
  if(x2%2==0)y2=w-y2+1;
//  cout<<"x1=="<<x1<<"   y1=="<<y1<<endl;
//  cout<<"x2=="<<x2<<"   y2=="<<y2<<endl;
  int ans=abs(x1-x2)+abs(y1-y2);
  cout<<ans<<endl;
  return 0;
}
